<template>
	<view class="">
		<view class="my-list padding-0">
			<u-list :height="swiperHeight" @scrolltolower="scrolltolower">
				<u-list-item v-for="(scheme, orderIx) in dataList" :key="orderIx">
					<view 
						class="item flex justify-between align-center" 
						@click="$u.route('/pages/shop/IncentivePolicy/edit',{ id:scheme.id})">
						<view class="flex flex--row justify-between">
							<text class="fsize-30">{{scheme.schemeName}}</text>
							<view class="fsize-24 line-gray mt-10">
							<text>{{scheme.amount}}元入股</text> 
							<text class="ml-10">| {{scheme.rechargeBalance?'可消费':'不消费'}},</text>
							<text class="ml-10">{{scheme.refundable?'可退':'不可退'}}</text>
						</view>
						</view>
						<view @click.stop>
							<u-tag text="删除" type="error" plain @click="onDel(orderIx)"></u-tag>
						</view>
					</view>
				</u-list-item>
			</u-list>
		</view>
		<uni-fab
			:popMenu="false" 
			ref="fab" 
			horizontal="right" 
			:pattern="pattern"
			@fabClick="$u.route('/pages/shop/IncentivePolicy/edit')"
		/>
	</view>
</template>

<script>
	import { formatDate } from '@/common/utils/commonHelper.js'
	import listHeightMixin from '@/common/computedAltitude.js'
	export default {
		mixins:[listHeightMixin],
		data() {
			return {
				keyword: '',
				dataId: 0,
				dataList:[],
				searchData: {
					itemType: 0,
					page: 1,
					limit: 50
				},
				pattern: { buttonColor :'#e54d42' },
				loadmore:{
					status: 'loadmore',
					iconType: 'flower',
					loadText: {
						loadmore: '轻轻上拉',
						loading: '努力加载中',
						nomore: '实在没有了'
					},
				},
			}
		},

		onLoad(option) {
			this.getData()
		},
		methods: {
			onDel(ix){
				let that = this
				uni.showModal({
					title: '提示',
					content: `确定要删除${that.dataList[ix].schemeName}吗?`,
					success: function(res) {
						if (res.confirm) {
							that.$reqJsonPost('BonusSchemeDoDelete', { id: that.dataList[ix].id, itemType: 0 }).then(res => {
								if (res.code === 0) {
									that.dataList.splice(ix, 1)
								}
							})
						}
					}
				})
			},
			scrolltolower() {
				if (this.loadmore.status === 'loadmore') {
					this.getData()
				}
			},
			upData(){
				this.searchData.page = 1
				this.dataList = []
				this.getData()
			},
			getData() {
				this.$reqPost('GetBonusSchemeList', this.searchData).then(res => {
					this.dataList = [...this.dataList, ...res.data]
					if (res.count > this.dataList.length) {
						this.loadmore.status = 'loadmore'
						this.searchData.page++
					} else {
						// 数据已加载完毕
						this.loadmore.status = 'nomore'
					}
				})
			},
		}

	}
</script>

<style lang="scss" scoped>
	.group_title {
		display: block;
		margin-left: 20rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		font-size: 28rpx;
		color: #666;
	}
</style>
